var express = require('express');
var router = express.Router();
var { hunshaTypeModel, hunshaModel, imgModel,WeddingDressModel,WeddingDressSearchModel } = require('../../model/model')
/* GET users listing. */

// 获取所有婚纱
router.get('/gethunsha',async (req,res)=>{
    let data=await hunshaModel.find().populate('imgid')
    console.log(data);
    res.send({
        code:200,
        msg:'获取婚纱成功',
        data
    
    })
})

//获取所有婚纱照
router.get('/getimg',async(req,res)=>{
    let imgs = await imgModel.find()
    res.send({imgs})
})

// 获取婚纱类型
router.get('/gethunshatype', async (req, res) => {
  let data = await hunshaTypeModel.find()
  res.send({
    code: 200,
    msg: '获取婚纱类型成功',
    data
  })
})

//耿浩志

//首页婚纱照展示和首页点击获取该套婚纱照片
router.get('/show_hunsha',async (req,res)=>{
    //获取首页展示的所有图片
    let show_list=await WeddingDressModel.find()
    res.send({
        code:200,
        msg:'获取首页婚纱照成功',
        show_list
    })
})

router.get('/search_hunsha',async (req,res)=>{
    let {kind}=req.query
    let obj=JSON.parse(kind)
    //获取点击后所有婚纱照片合集
    let search_list=await WeddingDressSearchModel.find({kind:obj.kind})
    res.send({
        code:200,
        msg:'获取点击后婚纱照成功',
        search_list
    })
})

module.exports = router;
